﻿using System;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ALDIOrganizer.Properties;
using Generator;

namespace ALDIOrganizer
{
    public partial class MainForm
    {
        private void CurrentRota_OnModifiedChanged(bool pNewValue)
        {            
            btnSaveRota.Enabled = pNewValue;
            if (pNewValue == false)
            {
                svRota.Focus();
            }
        }

        private bool CurrentRota_OnShuttingDayWithShifts(Weekday[] days)
        {
            var decision = MessageBox.Show(
                Resources.MESSAGEBOX_QUESTION_ClosingStoreDeletesShifts_MESSAGE,
                Resources.MESSAGEBOX_QUESTION_ClosingStoreDeletesShifts_CAPTION,
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning);
            return decision == DialogResult.Yes;
        }

        private static void CurrentRota_OnViolatingRequest(long pEmployeeID, Request[] pRequests)
        {
            var message = Resources.MESSAGEBOX_WARNING_ViolatingTimeOffRequest_MESSAGE;
            if (message.Contains("#"))
            {
                var list = new StringBuilder();
                foreach (var request in pRequests)
                {
                    list.Append(
                        request +
                        Environment.NewLine);
                }
                message = message.Replace(
                    "#",
                    list.ToString());
            }
            MessageBox.Show(
                message,
                Resources.MESSAGEBOX_WARNING_ViolatingTimeOffRequest_CAPTION,
                MessageBoxButtons.OK,
                MessageBoxIcon.Warning);
        }
    }
}
